package com.java.zhuiyun.api.pictureidiomquestion.controller;

import com.java.zhuiyun.annotation.OptLog;
import com.java.zhuiyun.api.pictureidiomlevel.model.PictureIdiomLevelModel;
import com.java.zhuiyun.api.pictureidiomquestion.entity.PictureIdiomQuestion;
import com.java.zhuiyun.api.pictureidiomquestion.model.PictureIdiomQuestionModel;
import com.java.zhuiyun.api.pictureidiomquestion.service.PictureIdiomQuestionService;
import com.java.zhuiyun.common.response.CommonConstants;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName PictureIdiomQuestion
 * @Description TODO
 * @Author MJL
 * @Date 2023/9/14 16:57
 **/
@RestController
@RequestMapping("/PictureIdiomQuestion")
@Api(tags = "看图猜成语词库信息管理")
public class PictureIdiomQuestionController {
    @Resource
    PictureIdiomQuestionService pictureIdiomQuestionService;
    /**
    * @Author MJL
    * @Description todo 添加看图猜成语的题库
    * @Date 2023/9/14 17:04
    * @Return  * @param null
    */
    @PostMapping("/addPictureIdiomQuestion")
    @ApiOperation(value = "看图猜成语后台管理系统添加成语")
    @OptLog(modular = "看图猜成语词库信息管理", type = CommonConstants.ADD, describe = "看图猜成语添加成语")
    public CommonResult addPictureIdiomQuestion(MultipartFile file, PictureIdiomQuestionModel pictureIdiomQuestionModel){
        return CommonResult.ok(pictureIdiomQuestionService.addPictureIdiomQuestion(file,pictureIdiomQuestionModel));
    }
    /**
    * @Author MJL
    * @Description todo 查询所有成语信息
    * @Date 2023/9/14 23:26
    * @Return  * @param null
    */
    @GetMapping("/queryPictureIdiomQuestion")
    @ApiOperation(value = "看图猜成语后台管理系统全查成语")
    @OptLog(modular = "看图猜成语词库信息管理", type = CommonConstants.SELECT, describe = "看图猜成语全查成语")
    public CommonResult queryPictureIdiomQuestion(PictureIdiomQuestionModel pictureIdiomQuestionModel, PageRequest pageRequest){
        return CommonResult.ok(pictureIdiomQuestionService.queryPictureIdiomQuestion(pictureIdiomQuestionModel,pageRequest));
    }
    /**
    * @Author MJL
    * @Description todo 查询出当前成语的错别字
    * @Date 2023/9/15 9:55
    * @Return  * @param null
    */
    @GetMapping("/queryPictureIdiomQuestionTypos")
    @ApiOperation(value = "查询出当前成语的错别字")
    public CommonResult queryPictureIdiomQuestionTypos(PictureIdiomQuestion pictureIdiomQuestion) {
        return CommonResult.ok(pictureIdiomQuestionService.queryPictureIdiomQuestionTypos(pictureIdiomQuestion));
    }
    /**
    * @Author MJL
    * @Description todo 根据id查询成语
    * @Date 2023/10/23 9:17
    * @Return  * @param null
    */
    @GetMapping("/getByIdIdiom")
    @ApiOperation(value = "根据id查询成语")
    public CommonResult getByIdIdiom(Integer id) {
        return CommonResult.ok(pictureIdiomQuestionService.getByIdIdiom(id));
    }
    /**
    * @Author MJL
    * @Description todo 修改成语信息
    * @Date 2023/10/11 20:02
    * @Return  * @param null
    */
    @PutMapping("/updatePictureIdiom")
    @ApiOperation(value = "看图猜成语后台管理系统修改成语")
    @OptLog(modular = "看图猜成语词库信息管理", type = CommonConstants.UPDATE, describe = "看图猜成语修改成语")
    public CommonResult updatePictureIdiom (MultipartFile file,PictureIdiomQuestionModel pictureIdiomQuestionModel) {
        return CommonResult.ok(pictureIdiomQuestionService.updatePictureIdiom(file,pictureIdiomQuestionModel));
    }
    /**
    * @Author MJL
    * @Description todo 根据关卡查询游戏内成语信息
    * @Date 2023/10/13 13:31
    * @Return  * @param null
    */
    @GetMapping("/getByIdIdiomByLevel")
    @ApiOperation(value = "根据关卡查询游戏内成语信息")
    public CommonResult getByIdIdiomByLevel(Integer id) {
        return CommonResult.ok(pictureIdiomQuestionService.getByIdIdiomByLevel(id));
    }
    /**
    * @Author MJL
    * @Description todo 批量删除成语
    * @Date 2023/10/16 9:36
    * @Return  * @param null
    */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "看图猜成语后台管理系统批量删除成语")
    @OptLog(modular = "看图猜成语词库信息管理", type = CommonConstants.DELETE, describe = "看图猜成语删除成语")
    public CommonResult deletePictureIdiom(@PathVariable("id") String id) {
        return CommonResult.ok(pictureIdiomQuestionService.deletePictureIdiom(id));
    }
    /**
    * @Author MJL
    * @Description todo 查询当前关卡成语数量
    * @Date 2023/10/16 19:53
    * @Return  * @param null
    */
    @GetMapping("/queryLevelNum")
    @ApiOperation(value = "查询当前关卡成语数量")
    public CommonResult queryLevelNum(Integer id) {
        List<PictureIdiomLevelModel> list = pictureIdiomQuestionService.queryLevelNum(id);
        return CommonResult.ok(list);
    }
    /**
    * @Author MJL
    * @Description todo 查询所属关卡下拉框
    * @Date 2023/10/17 11:06
    * @Return  * @param null
    */
    @GetMapping("/queryLevel")
    @ApiOperation(value = "查询所属关卡下拉框")
    public CommonResult queryLevel(Integer id) {
        return CommonResult.ok(pictureIdiomQuestionService.queryLevel(id));
    }
    /**
    * @Author MJL
    * @Description todo 删除单个成语信息
    * @Date 2023/10/23 9:16
    * @Return  * @param null
    */
    @DeleteMapping("/deletePictureIdioms")
    @ApiOperation(value = "看图猜成语后台管理系统删除成语")
    @OptLog(modular = "看图猜成语词库信息管理", type = CommonConstants.ADD, describe = "看图猜成语删除成语")
    public CommonResult deletePictureIdiom (Integer id) {
        return CommonResult.ok(pictureIdiomQuestionService.deletePictureIdioms(id));
    }
//    @DeleteMapping("/deletePictureIdiom")
//    @ApiOperation(value = "看图猜成语后台管理系统删除成语")
//    @OptLog(modular = "看图猜成语词库信息管理", type = CommonConstants.ADD, describe = "看图猜成语删除成语")
//    public CommonResult deletePictureIdiom (Integer id) {
//        return CommonResult.ok(pictureIdiomQuestionService.deletePictureIdiom(id));
//    }
//    @GetMapping("/user")
//    public void user(MultipartFile file) {
//        System.out.println(file);
//    }
}
